home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / PLIST.ASM < prev    next >
Assembly Source File  |  1986-06-27  |  29KB  |  963 lines

  1.      name    plist
  2.     page    78,132
  3.     title    PLIST12 --- Print text file (version 1.2A)
  4.  
  5. ;    Zider Brothers,    San Francisco
  6. ;
  7. ;    Based on LIST.ASM by Ray Duncan
  8. ;
  9. ;6.27    Fixed output buffer bug.
  10. ;    Added version id on help screen.
  11. ;    Added PLIST id to error messages.
  12. ;    Fixed automatic computation of remaining available space 
  13. ;      (courtesy Chris Dunford via Vern Buerg).
  14. ;
  15. ;6.5.86    Fixed title buffer init to conform to page offset, line
  16. ;      width parms.
  17. ;    Fixed end-of-input processing (now does not pump out extra
  18. ;      line with pg_offset pad plus line feed)
  19. ;
  20. ;6.4.86    Add /7 option to strip hi-bit (make ok 8-bit the default now)
  21. ;    Enlarged I/O buffers to max space available (64K assumed - may 
  22. ;      blow system if full 64KB not available for code).
  23. ;    DEL char (07Fh or 127 decimal) is now treated as low-order control
  24. ;      character. 
  25. ;    Add /b option for blanks substituted for low-order control chars 
  26. ;      (Default is that non-special treatment control chars are discarded 
  27. ;      from the output listing stream to keep output devices from
  28. ;      interpreting WordStar embedded print control chars).
  29. ;    Change default output file to zz.spl (from zz.lst).
  30. ;    Speed on AT 6/1 around 90-100K bps, and about 11-17,000 lines per minute.
  31. ;
  32. ;5.8.85    Add std    error out for error messages
  33. ;    Disable    code that toggles lpi, cpi on exit if parm was exercised
  34. ;    Change to COM file format
  35. ;    Input buffer moved to end, fill    above program
  36. ;    Change input block size    to 4096    bytes (for DOS 2.0 hard    disk)
  37. ;    Conversion speed from 14K bps to 19K bps, depending on tabs expansion
  38. ;    Make ZZ.LST the default (file) output--21K-24K bps (bits per second)
  39. ;
  40. ;5.7.85    Make compressed, 8 lpi the default (using IBM PC Graphics printer)
  41. ;    Add /N option to get uncompressed print    ("normal" print)
  42. ;    Exit print without changing settings if    none set, toggle back if set
  43. ;    Disable    FF bracketing, make no FF's at begin/end the default
  44. ;    Add /F switch to enable    lead-in    FF (tail end still disabled)
  45. ;    Add /S switch to print to std output device (so    can redirect to    file)
  46. ;    Change name to PLIST to    avoid confusion    with LIST545, etc by Vern Buerg
  47. ;    Add syntax, options help when null command line    tail
  48. ;    Add page offset    of 8 spaces
  49. ;    Added clarifying comments, code section identification breaks.
  50. ;
  51. ;5.6.85    Hack to    add 8 Lines Per    Inch option (/8)
  52. ;
  53. ;-----original documentation:
  54. ;
  55. ; LIST --- a utility to    print out text files with titles and page
  56. ; numbers on  the current list device.    The high bit of    all
  57. ; characters is     stripped [this option now must be specified on the command
  58. ; line with the /7 option], so that raw Wordstar or other word
  59. ; processing files can    be listed.  Embedded form feed codes are
  60. ; recognized, and tabs are  expanded.  Unknown control codes (such
  61. ; as the ^B and    ^U codes found in Wordstar documents) are discarded.
  62. ; If using an Epson printer, compressed    mode can be turned on with
  63. ; /C switch in command so that lines up    to 128 characters long will
  64. ; fit on a normal page.     Requires PC-DOS 2.0 or    MS-DOS 2.0.
  65.  
  66. ; Used in the form:
  67. ; A>LIST path\filename.ext  ["title text"]  [/C]
  68. ; (items in square brackets are    optional)
  69.  
  70. ; version 1.0    February 28, 1984
  71. ; Copyright (c)    1984 by    Ray Duncan
  72. ; May be freely    reproduced for non-commercial use.
  73.  
  74. cr    equ    0dh        ;ASCII carriage    return
  75. lf    equ    0ah        ;ASCII line feed
  76. ff    equ    0ch        ;ASCII form feed
  77. eof    equ    01ah        ;End of    file marker
  78. tab    equ    09h        ;ASCII tab character
  79. blank    equ    20h        ;space character
  80.  
  81. command        equ    80h    ;buffer    for command tail
  82.  
  83. prog_size    =    offset end_code        ; s/b about 09f6h
  84. end_segment    equ    0ffffh
  85. stack_space    equ    100h
  86. avail        =    end_segment-(offset end_code - cseg) - stack_space
  87. ;avail2        =    end_segment-prog_size-stack_space    ;gives error
  88.         public    buf_size
  89. ;buf_size    equ    1024
  90. buf_size    equ    avail/2
  91.         public    output_buffer
  92. output_buffer    equ    prog_size+buf_size
  93. chk_stack    equ    output_buffer+buf_size+1
  94. stack_start    equ    end_segment-stack_space+1
  95.  
  96. inblksize    equ    buf_size
  97. outblksize    equ    buf_size
  98. ;inblksize    equ    8192    ;size of block reads from input    file
  99. ;outblksize    equ    8192    ;size of block writes to output file
  100. pg_offset    equ    8    ;set page offset to 8 spaces
  101. linesize equ    132-pg_offset    ;maximum length    of output line
  102. page6lpi    equ    58    ;58 out of 66 lines
  103. page8lpi    equ    80    ;80 of of 88 lines
  104. heading_lines    equ    3    ;number    of lines in page heading
  105.  
  106. std_out        equ    1    ;standard output
  107. std_error    equ    2    ;standard error--not redirectable
  108. std_printer    equ    4    ;standard printer
  109.     page
  110. cseg    segment    para public 'CODE'
  111.  
  112. ;old assume:
  113. ;    assume    cs:cseg,ds:data,es:data,ss:stack
  114.     assume    cs:cseg,ds:cseg,es:cseg,ss:cseg
  115.     org    100H
  116. ENTRY:    jmp    start
  117. ;
  118. ;DATA area at end of the program.
  119. ;
  120. who_am_i    db    'PLIST12: Zider Brothers, San Francisco'
  121. start:
  122. list    proc    far        ;entry point from PC-DOS
  123.  
  124.     push    ds        ;save DS:0000 for final
  125.     xor    ax,ax        ;return    to PC-DOS
  126.     push    ax
  127.  
  128. list13:                ;make sure we're running under DOS 2.0.
  129.     mov    ah,30h
  130.     int    21h
  131.     cmp    al,2
  132.     jae    list01        ;proceed, DOS 2.0 or greater
  133.     mov    dx,offset msg3    ;DOS 1.x --- print error message
  134.     mov    cx,msg3_len
  135.     jmp    list9
  136.  
  137.  
  138. ;----------------------------------------------------------
  139. ;        Process command line
  140.  
  141. list01:    call    get_title    ;get listing title from
  142.                 ;command line tail.
  143.     call    get_switch    ;look for /C, /N, /6, /8, etc switches,    if any
  144.     call    get_filename    ;get path and file spec. for
  145.                 ;input file from command line tail.
  146.  
  147.     jnc    list15        ;jump, got acceptable name.
  148.     mov    dx,offset msg2    ;missing or illegal filespec,
  149.     mov    cx,msg2_len
  150.     jmp    list9        ;print error message and exit.
  151.  
  152. ;----------------------------------------------------------
  153. ;        Open input file
  154.  
  155. list15:    call    open_input    ;now try to open input file
  156.     jnc    list2        ;jump,opened input ok
  157.     mov    dx,offset msg1    ;open of input file failed,
  158.     mov    cx,msg1_len
  159.     jmp    list9        ;print error msg and exit.
  160.  
  161. ;----------------------------------------------------------
  162. ;        Open output file
  163.  
  164. list2:
  165.     cmp    s_switch,0    ;output    to std out?
  166.     jne    list25        ;jump if DOS std output    selected
  167.     call    open_zzlst    ;open default output file
  168.     jnc    list25        ;skip if ok open
  169.     mov    dx,offset zzmsg    ;opening default file error
  170.     mov    cx,zzmsg_len
  171.     jmp    list9        ;print error msg and xit.
  172.  
  173. ;----------------------------------------------------------
  174. ;        Initialization
  175.  
  176. list25:    call    init_buff    ;initialize input deblocking buffer
  177.  
  178. ;----------------------------------------------------------
  179. ;        Set page, printer configuration
  180.  
  181. list20:    test    compress_switch,-1 ;was    /C switch found?
  182.     jz    list21
  183.     call    compress_on    ;yes,turn on compressed    print mode
  184. list21:    test    ate_lpi,-1    ;/8 switch found?
  185.     jz    list22
  186.     call    ate_on
  187. list22:    test    six_lpi,-1    ;/6 switch found?
  188.     jz    list23
  189.     call    six_on
  190. list23:    test    norm_switch,-1    ;was /N    switch found?
  191.     jz    list3
  192.     call    compress_off
  193.  
  194. ;===============================================================;
  195. ;        Main program control loop            ;
  196. ;                                ;
  197.  
  198. ;----------------------------------------------------------
  199. ;        Process character input stream
  200.  
  201. list3:                
  202.     call    get_char    ;read 1    character from input.
  203.     cmp    al,20h        ;is it a low-order control code?
  204.     jb    short list30    ;yes, go check out what kind.
  205.     cmp    al,07fh        ;not low-order, pivot on DEL char (127 decimal)
  206.     jb    list4        ;ok char, write to list device.
  207.     je    short list30    ;treat it like low-order control char.
  208.  
  209. mod1    label    word
  210.     nop            ;high bit is set on char = upper 128 chars.
  211.     nop            ;..two bytes here may be modified to 
  212.                 ;  'and  al,07h' by /7 option to strip hi-bit.
  213.                 ;  Otherwise code falls through to jmp:
  214.     jmp    list4        ;now write to list device.
  215.  
  216. list30:    cmp    al,tab        ;is it a tab command?
  217.     je    list5        ;yes,jump to special processing.
  218.     cmp    al,cr        ;carriage return?
  219.     jne    list31        ;
  220.     mov    column,0    ;carriage return, store it into output
  221.     jmp    list45        ;  string and initialize column count.
  222. list31:    cmp    al,lf        ;is it a line feed?
  223.     je    list7        ;yes,jump to special processing. (force print)
  224.     cmp    al,ff        ;is it a form feed?
  225.     je    list6        ;yes, jump to special processing.
  226.     cmp    al,eof        ;is it end of file marker?
  227.     je    list8        ;yes,jump to close files.
  228.     test    blank_sub,-1    ;substitute blank char for control char?    
  229.     jz    list32        ;no
  230.     mov    al,blank    ;yes, replace ctl char with b